﻿using Microsoft.Extensions.DependencyInjection;
using System;
using Test.EventBus2.Core;
using Test.EventBus2.Message.Events.Orders;
using Test.EventBus2.Order.Handlers;
using Test.EventBus2.Order.Services;

namespace Test.EventBus2.Order
{
    class Program
    {
        static void Main(string[] args)
        {
            var services = new ServiceCollection();
            services.UseKafkaSubsrcibeStore().AddEventBus().AddRebusHandler<OrderHandler>().UseEventBus(bus => {
                bus.HandleEvent();
               

            });

            services.AddSubscrbe<OrderCreationEvent>();
            services.AddSubscrbe<PayemntedEvent>();
            services.AddSingleton(typeof(IOrderService), typeof(OrderService));
            var orderService = services.BuildServiceProvider().GetService<IOrderService>();
            orderService.CreateOrder(new OrderInfo 
            {
                Id=Guid.NewGuid(),
                Name="测试买个东西"
            });
            Console.Read();
        }
    }
}
